package com.ofps.web.controller.flow;

import com.alibaba.fastjson.JSONObject;
import com.ofps.common.core.domain.AjaxResult;
import com.ofps.common.exception.ServiceException;
import com.ofps.flow.service.IEnterFlowInfoInstService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/flowInst")
public class FlowInstController {

    @Autowired
    private IEnterFlowInfoInstService iEnterFlowInfoInstService;

    /**
     * 获取我的申请-详情数据
     * @param jsonObject 请求参数
     * @return 我的申请-详情数据
     */
    @PostMapping("/findInstDetail")
    public AjaxResult findInstDetail(@RequestBody JSONObject jsonObject) {
        if (jsonObject.getString("flowInstId") == null) {
            throw new ServiceException("请求参数确实, 请检查");
        }
        return AjaxResult.success(iEnterFlowInfoInstService.findInstDetail(jsonObject));
    }

    /**
     * 建立流程实例接口
     * @return 成功或失败
     */
    @PostMapping("/insertFlowInst")
    public AjaxResult insertFlowInst(@RequestBody JSONObject jsonObject) {
        iEnterFlowInfoInstService.insertFlowInst(jsonObject);
        return AjaxResult.success();
    }

}
